package cn.com.infohold.smartcity.data;

import cn.com.infohold.smartcity.api.bean.Session;
import cn.com.infohold.smartcity.api.bean.UserInfo;
import library.utils.XmlEditor;

/**
 * Created by apple on 2017/4/19.
 */

public class XmlData extends XmlEditor {
    private static final XmlData INSTANCE = new XmlData();

    private static final String KEY_USERINFO = "sp.data.key.userinfo";
    private static final String KEY_USERNAME = "sp.data.key.username";
    private static final String KEY_PASSWORD = "sp.data.key.password";


    public static XmlData getInstance() {
        return INSTANCE;
    }

    @Override
    protected boolean isAutoCommit() {
        return true;
    }

    public UserInfo getUserInfo() {
        return getSerializable(KEY_USERINFO);
    }

    public void setUserInfo(UserInfo userInfo) {
        putSerializable(KEY_USERINFO, userInfo);
    }

    public void setUsername(String username) {
        putString(KEY_USERNAME, username);
    }

    public String getUsername() {
        return getString(KEY_USERNAME, null);
    }

    public void setPassword(String username) {
        putString(KEY_PASSWORD, username);
    }

    public String getPassword() {
        return getString(KEY_PASSWORD, null);
    }
}
